package com.zijidelu.luframework.base.exception;

import com.zijidelu.luframework.base.message.Message;
import com.zijidelu.luframework.base.message.impl.GenericMessage;

/**
 * 业务运行期异常。
 *
 * @author ZIJIDELU
 * @datetime 2024/9/2700:33
 */
public class BizException extends RuntimeException {
    private final Integer code;

    public Integer getCode() {
        return code;
    }

    public BizException(Message message) {
        super(message.getText());
        this.code = message.getCode();
    }

    public BizException(String message) {
        super(message);
        this.code = GenericMessage.BIZ_EXCEPTION.getCode();
    }

    public BizException(String message, Throwable cause) {
        super(message, cause);
        this.code = GenericMessage.BIZ_EXCEPTION.getCode();
    }

    public BizException(Throwable cause) {
        super(cause);
        this.code = GenericMessage.BIZ_EXCEPTION.getCode();
    }

}
